<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	pageContext.setAttribute("contextPath", request.getContextPath());
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${page.title}</title>
</head>
<body>
	<input id="pageId" name="pageId" type="hidden" value="${page.id}">
	<div>
		<form id="${page.name }" class="page">
			<table>
				<c:forEach var="field" items="${ page.formFields }" varStatus="status">
					<c:if test="${not field.hidden and (status.first or field.fullLine or status.count % 2 eq 0)}">
						<tr>
					</c:if>
					<c:choose>
						<c:when test="${field.hidden }">
							<input id="${field.name }" name="${field.name }" type="hidden" value="">
						</c:when>
						<c:otherwise>
							<th>
								${field.display }
							</th>
							<td ${field.fullLine ? "colspan=\"3\"" : ""}>
								<div id="${field.name }" fieldName="${field.name}" fieldType="${field.component }"></div>
							</td>
						</c:otherwise>
					</c:choose>
					<c:if test="${not field.hidden and ( status.last or field.fullLine or (status.count + 1) % 2 eq 0)}">
						</tr>
					</c:if>
				</c:forEach>
	        </table>
		</form>
	</div>
</body>
<link rel="stylesheet" type="text/css" href="${contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${contextPath }/js/easyui/themes/color.css">
<script type="text/javascript" src="${contextPath }/js/easyui/jquery.min.js"></script>
<script type="text/javascript" src="${contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${contextPath }/js/components/inputText.js"></script>
<script type="text/javascript" src="${contextPath }/js/components.js"></script>
<script type="text/javascript">

	var defaultValue = JSON.parse('${empty dataModel ? "{}" : dataModel}');
	var fieldAttrs = JSON.parse('${empty fieldAttr ? "{}" : fieldAttr}');

	$("#${page.name } [fieldType]").each(function() {
		var fieldName = $(this).attr("fieldName");
		var fieldType = $(this).attr("fieldType");
		var component = components[fieldType];

		// 参数：默认数据、默认属性
		if (component) {
			component.init(this, defaultValue[fieldName], fieldAttrs[fieldName]);
		}
	});
</script>
</html>